#测试用户管理页面
from time import sleep
from common.Untils import WJDriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
class WJUser:
    url = ""
    driver = ""

    def __init__(self):
        #WJLogin.WJLogin().LoginSuccess()
        self.url = "http://8.155.1.153:8081/system/user"
        self.driver = WJDriver.driver
        self.driver.get(self.url)
        WJDriver.Login()
        #sleep(2)
        #点击系统管理
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/aside/div/div[1]/ul/li[6]/div/span/div").click()
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/aside/div/div[1]/ul/li[6]/ul/li[1]").click()

    def TestByUserFunction(self):
        # self.driver.find_element(By.XPATH,"").send_keys()
        # self.driver.find_element(By.XPATH,"").click()
        sleep(1)
        #1.输入存在的用户名，点击查询##############################################################
            #输入用户名
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/form/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("zzj24")
            #点击查询
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/button").click()
        print("用户管理页面:1正常")
        #2.输入不存在的用户名，点击查询############################################################
            # 输入用户名
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/form/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("zzj2411111")
            # 点击查询
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/button").click()
        print("用户管理页面:2正常")
        #3.点击重置#############################################################################
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[1]").click()
        print("用户管理页面:3正常")
        #4.点击新建，输入内容各项正确，点击确定######################################################
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button").click()
            #输入用户名
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("自动化"+WJDriver.name)
            #输入登录名
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("自动化"+WJDriver.name)
            #输入密码
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[2]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("123456")
            #输入确认密码
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[2]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("123456")
            #选择性别
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[1]/div/div/div[2]/div/div/div/div/span[1]/input").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[1]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[1]").click()
            #选择状态
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[2]/div/div/div[2]/div/div/div/div[1]/span[1]/input").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[2]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[1]").click()
            #输入手机号
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("123456789")
            #输入邮箱
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("123456@gmail.com")
            #选择角色列表
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[3]/div/div/div[2]/div/div/div/div/span[1]/input"). send_keys("test")
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        print("用户管理页面:4正常")
        #5.点击新建，全部不填写###################################################################
            #点击新建
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button").click()
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[1]/div/button").click()
        print("用户管理页面:5正常")
        #6.点击新建，只填写用户名#################################################################
            # 点击新建
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button").click()
            # 输入用户名
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("自动化" + WJDriver.name)
            # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[1]/div/button").click()
        print("用户管理页面:6正常")
        #7.点击新建，只填写登录名，输入密码，状态####################################################
            #点击新建
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button").click()
            #输入登录名
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("自动化" + WJDriver.name)
            #输入密码
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[2]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("123456")
            #选择状态
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[2]/div/div/div[2]/div/div/div/div[1]/span[1]/input").click()
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[2]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[1]").click()
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[1]/div/button").click()
        print("用户管理页面:7正常")
        #8.点击新建，只填写输入密码，性别，手机号############################################
            #点击新建
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button").click()
            #输入密码
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[2]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("123456")
            #选择性别
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[1]/div/div/div[2]/div/div/div/div/span[1]/input").click()
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[1]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[1]").click()
            #输入手机号
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("123456789")
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[1]/div/button").click()
        print("用户管理页面:8正常")
        #9.点击新建，只填写登录名，输入密码，状态，手机号，角色列表#####################################
            # 点击新建
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button").click()
            # 输入登录名
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("自动化" + WJDriver.name)
            # 输入密码
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[2]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("123456")
            # 选择状态
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[2]/div/div/div[2]/div/div/div/div[1]/span[1]/input").click()
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[2]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[1]").click()
            # 输入手机号
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("123456789")
            # 选择角色列表
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[3]/div/div/div[2]/div/div/div/div/span[1]/input").send_keys("test")
            # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[1]/div/button").click()
        print("用户管理页面:9正常")
        #10.点击新建，只填写输入密码，确认密码，手机号，邮箱###########################################
            # 点击新建
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button").click()
            # 输入密码
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[2]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("123456")
            # 输入确认密码
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[2]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("123456")
            # 输入手机号
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("123456789")
            # 输入邮箱
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("123456@gmail.com")
            # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[1]/div/button").click()
        print("用户管理页面:10正常")
        #11.点击新建，只填写登录名，性别，手机号，邮箱，角色列表########################################
            # 点击新建
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button").click()
            # 输入登录名
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("自动化" + WJDriver.name)
            # 选择性别
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[1]/div/div/div[2]/div/div/div/div/span[1]/input").click()
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[1]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[1]").click()
            # 输入手机号
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("123456789")
            # 输入邮箱
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("123456@gmail.com")
            # 选择角色列表
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[3]/div/div/div[2]/div/div/div/div/span[1]/input").send_keys("test")
            # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[1]/div/button").click()
        print("用户管理页面:11正常")
        #12.点击新建，只填写输入密码，确认密码，状态##################################################
            # 点击新建
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button").click()
            # 输入密码
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[2]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("123456")
            # 输入确认密码
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[2]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("123456")
            # 选择状态
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[2]/div/div/div[2]/div/div/div/div[1]/span[1]/input").click()
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[3]/div/div[2]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[1]").click()
            # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[1]/div/button").click()
        print("用户管理页面:12正常")
        #13.点击新建，只填写登录名#################################################################
            # 点击新建
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button").click()
            # 输入登录名
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("自动化" + WJDriver.name)
            # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[1]/div/button").click()
        print("用户管理页面:13正常")
        #14.点击新建，只填写角色列表################################################################
            # 点击新建
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button").click()
            # 选择角色列表
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[4]/div/div[3]/div/div/div[2]/div/div/div/div/span[1]/input").send_keys("test")
            # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[1]/div/button").click()
        print("用户管理页面:14正常")
        #15.点击编辑#############################################################################
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[8]/div/div[1]").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[1]/div/button").click()
        print("用户管理页面:15正常")
        #16.点击更多，重置密码#####################################################################
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[8]/div/div[2]/a").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div/ul/li[1]/span").click()
        self.driver.find_element(By.XPATH, "/html/body/div[6]/div/div[2]/div/div[2]/div/div/div[1]/div/span/input").send_keys("123456")
        self.driver.find_element(By.XPATH, "/html/body/div[6]/div/div[2]/div/div[2]/div/div/div[2]/button[2]").click()
        print("用户管理页面:16正常")



#         self.driver.quit()
# user=WJUser()
# user.TestByUserFunction()